package fy.com.service.user;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import fy.com.entity.Role;

import fy.com.util.PageData;

import fy.com.dao.DaoSupport;
import fy.com.entity.Page;

@Service("roleService")
public class RoleService {
	
	@Resource(name = "daoSupport")
	private DaoSupport dao; 
	
	/**
	 * 通过id查找
	 */
	public PageData findObjectById(PageData pd) throws Exception {
		return (PageData)dao.findForObject("RoleMapper.findObjectById", pd);
	}
	
	/*
	* 新增
	*/
	public void save(PageData pd)throws Exception{
		dao.save("RoleMapper.save", pd);
	}
	
	/*
	* 删除
	*/
	public void delete(PageData pd)throws Exception{
		dao.delete("RoleMapper.delete", pd);
	}
	
	/*
	* 修改
	*/
	public void edit(PageData pd)throws Exception{
		dao.update("RoleMapper.edit", pd);
	}
	
	/*
	*列表
	*/
	public List<PageData> list(Page page)throws Exception{
		return (List<PageData>)dao.findForList("RoleMapper.datalistPage", page);
	}
	
	/*
	*列表(全部)
	*/
	public List<PageData> listAll(PageData pd)throws Exception{
		return (List<PageData>)dao.findForList("RoleMapper.listAll", pd);
	}
	
	public List<Role> listAllRoles() throws Exception {
		return (List<Role>) dao.findForList("RoleMapper.listAllERRoles", null);
		
	}

}
